package com.yunxi.controller.sto;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import com.yunxi.sto.service.VehicleMaintainItemDubboService;
import com.yunxi.sto.pojo.VehicleMaintainItemVO;

/**
* <p>
* 车辆库存保养项目 前端控制器
* </p>
*
* @author Guan
* @since 2019-10-14
*/
@RestController
@RequestMapping("/admin/vehicleMaintainItem")
@Api(tags = "STO:vehiclemaintainitem", description = "车辆库存保养项目接口")
public class VehicleMaintainItemController {

    private static final Logger logger = LoggerFactory.getLogger(VehicleMaintainItemController.class);

    @Autowired
    VehicleMaintainItemDubboService vehicleMaintainItemDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询车辆库存保养项目分页")
    public ApiResult page(VehicleMaintainItemVO vehicleMaintainItemVO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(vehicleMaintainItemDubboService.findPageByVO(vehicleMaintainItemVO,pageNum,pageSize));
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询车辆库存保养项目列表")
    public ApiResult list(VehicleMaintainItemVO vehicleMaintainItemVO) throws Exception {
        return ResponseUtil.ok(vehicleMaintainItemDubboService.listByVo(vehicleMaintainItemVO));
    }

    @GetMapping("/load")
    @ApiOperation(value = "读取单个车辆库存保养项目")
    public ApiResult load(@RequestParam String id) throws Exception {
        return ResponseUtil.ok(vehicleMaintainItemDubboService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存车辆库存保养项目信息")
    public ApiResult save(@RequestBody VehicleMaintainItemVO vehicleMaintainItemVO) throws Exception {
        vehicleMaintainItemDubboService.saveOrUpdate(vehicleMaintainItemVO);
        return ResponseUtil.ok("success");
    }

    @PostMapping("/del")
    @ApiOperation(value = "删除车辆库存保养项目")
    public ApiResult del(@RequestBody List<VehicleMaintainItemVO> vehicleMaintainItemVOList) throws Exception {
        vehicleMaintainItemDubboService.removeByListVo(vehicleMaintainItemVOList);
        return ResponseUtil.ok("success");
    }

    /*@PostMapping("/export")
    @ApiOperation(value = "导出excel")
    public Object export(@RequestParam Map<String, Object> params) throws Exception {
        return ResponseUtil.ok(vehicleMaintainItemDubboService.findMapByList(params));
    }*/
}
